package com.wolainfo.simulator.model.tfi;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;

@Entity
@IdClass(com.wolainfo.simulator.model.tfi.TransactionSharelot.TransactionSharelotId.class)
public class TransactionSharelot implements Serializable{
    private static final long serialVersionUID = 3237341824001804841L;
    @Id
    private Integer           fundTransactionId;
    @Id
    private Integer           shareLotId;
    private BigDecimal        shares;
    private BigDecimal        loadPercentage;
    private BigDecimal        load;

    public Integer getFundTransactionId(){
        return fundTransactionId;
    }

    public void setFundTransactionId(Integer fundTransactionId){
        this.fundTransactionId = fundTransactionId;
    }

    public Integer getShareLotId(){
        return shareLotId;
    }

    public void setShareLotId(Integer shareLotId){
        this.shareLotId = shareLotId;
    }

    public BigDecimal getShares(){
        return shares;
    }

    public void setShares(BigDecimal shares){
        this.shares = shares;
    }

    public BigDecimal getLoadPercentage(){
        return loadPercentage;
    }

    public void setLoadPercentage(BigDecimal loadPercentage){
        this.loadPercentage = loadPercentage;
    }

    public BigDecimal getLoad(){
        return load;
    }

    public void setLoad(BigDecimal load){
        this.load = load;
    }

    public static class TransactionSharelotId{
        public TransactionSharelotId(){}
        private Integer fundTransactionId;
        private Integer shareLotId;

        public Integer getFundTransactionId(){
            return fundTransactionId;
        }

        public void setFundTransactionId(Integer fundTransactionId){
            this.fundTransactionId = fundTransactionId;
        }

        public Integer getAccountId(){
            return shareLotId;
        }

        public void setAccountId(Integer accountId){
            this.shareLotId = accountId;
        }

        @Override
        public boolean equals(Object obj){
            if(!(obj instanceof TransactionSharelotId))
                return false;
            TransactionSharelotId id = (TransactionSharelotId)obj;
            if(fundTransactionId.compareTo(id.fundTransactionId) != 0)
                return false;
            if(shareLotId.compareTo(id.shareLotId) != 0)
                return false;
            return true;
        }

        @Override
        public int hashCode(){
            return fundTransactionId.hashCode() * shareLotId.hashCode();
        }
    }
}
